/*
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.wallet.online.jwt;

import java.util.HashMap;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.wallet.online.jwt.util.GsonHelper;

/**
 * Masked Wallet Request Java object representation
 * https://devsite.googleplex.com
 * /payment-express/api-reference#jwt-requests-and-responses
 * 
 * @author pying(peng ying)
 * 
 */
public class MaskedWalletRequest extends JWTRequest {

  private final String AUD = "Google";
  private final String TYP = "google/wallet/online/masked/v2/request";

  private WalletBody request;

  /**
   * Constructor
   * 
   * @param s
   *          Select Enum to define the type of information being requested
   */
  public MaskedWalletRequest(
      WalletBody s) {
    setType(TYP);
    setAudience(AUD);
    setRequest(s); 
  }

  /**
   * Getter for Selectors
   * 
   * @return Selectors for Masked Wallet Request
   */
  public WalletBody getRequest() {
    return request;
  }

  /**
   * Setter for Selectors
   * 
   * @param selectors
   *          Pay/Ship Selectors
   */
  public void setRequest(WalletBody request) {
    this.request = request;
  }

  /**
   * Converts Object to HashMap to add in JWT payload
   * 
   * @return HashMap of JWT content
   */
  public HashMap<String, JsonElement> getContent() {
    Gson gson = GsonHelper.getGson();
    JsonObject obj = gson.toJsonTree(getRequest()).getAsJsonObject();
    HashMap<String, JsonElement> content = new HashMap<String, JsonElement>();
    content.put("request", obj);
    return content;
  }

}
